let DateUtil = {};

const MS_PER_DAY = 60 * 60 * 24 * 1000;

DateUtil.nowMS = function () {
    return new Date().getTime();
};

DateUtil.getIntervalSec = function (ts) {
    let now = new Date().getTime();
    let interval = now - ts;
    return Math.round(interval / 1000);
};

/**
 * ts1 ts2单位为ms
 * */
DateUtil.isSameDay = function (ts1, ts2) {
    return Math.floor(ts1 / MS_PER_DAY) === Math.floor(ts2 / MS_PER_DAY);
};

/**
 * 获取今日是星期几
 * 日 一 二 三 四 五 六
 * 0  1  2 3  4  5 6
 * */
DateUtil.getWeekDay = function () {
  return new Date().getDay();
};

module.exports = DateUtil;